﻿using MySql.Data.MySqlClient;
using System;
using System.Configuration;

namespace MyPLC
{
    public partial class Dapper: IDisposable
    {
        private bool isDisposed = false;        
        public Dapper()
        {

        }
        ~Dapper()
        {
            Dispose(true);
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool _isDisposed)
        {
            if (!isDisposed)
            {
                if (_isDisposed)
                {
                    //不能在此处dispose
                }
                isDisposed = true;
            }
        }
        public static MySqlConnection GetSqlConnection()
        {
            string ConnString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
            MySqlConnection connection = new MySqlConnection(ConnString);
            connection.Open();
            return connection;
        }
    }
}
